

<input type="button" onclick="onDownload()"  value="下载" />
<script src="jquery.js"></script>
<script>

   function onDownload(){
    $.ajax({
        url: "http://127.0.0.1:5000/api/report",
        method: "GET",
        headers: {
            'token': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
        },
        xhrFields: {
            responseType: "blob"
        },
        success: function(data) {
            down1(data, "我是中文");
        }
     });
     return false;
   }

   function down1(data, filename){
        var objectUrl = window.URL.createObjectURL(data);
        var a = document.createElement("a");
        a.setAttribute('style', 'display:none');
        a.setAttribute('href', objectUrl);
        a.setAttribute('download', decodeURI(filename));
        a.click();
        window.URL.revokeObjectURL(objectUrl);
   }

   function downloadFile (data, filename, type){
        if (type === void 0) { type = 'application/vnd.ms-excel'; }
        var blob = new Blob([data], { type: type });
        var objectUrl = URL.createObjectURL(blob);
        var a = document.createElement('a');
        a.setAttribute('style', 'display:none');
        a.setAttribute('href', objectUrl);
        a.setAttribute('download', decodeURI(filename));
        a.click();
        URL.revokeObjectURL(objectUrl);
    }
</script>